package com.ossean.match.dao;

import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.ossean.match.model.Project;


public interface ProjectDao {

	/*获得项目数据库中最新数据中的最大的id
	 *返回Integer而不是int 是为了防止在项目数为0时，sql返回null 与int类型不匹配
	 */
	/*@Select("select MAX(id) from projects")
	public Integer getNewLast();
	@Select("select id,name from projects where id>#{prjHistory} AND id<=#{prjNewLast}")
	public List<Project> getBatch(@Param("prjHistory")int prjHistory,@Param("prjNewLast") int prjNewLast);*/
	
	
	@Select("select MAX(id) from open_source_projects")
	public Integer getNewLast();
	
//	@Select("select id,name,url from open_source_projects where id>#{prjHistory} AND id<=#{prjNewLast}")
//	public List<Project> getBatch(@Param("prjHistory")int prjHistory,@Param("prjNewLast") int prjNewLast);
	
//	@Select("select * from ${table} limit #{position}, 1")
//	public TestResult1 getByPosition(@Param("table") String table, @Param("position") int position);
	
	@Select("select min(rank) as rank, min(rank_star) as rank_star from ${table} where Url = #{url}")
	public Project getProjByUrl(@Param("table") String table, @Param("url") String url);
	
	//批量获取项目对象
	@Select("select id,name,url,tags from open_source_projects where id>#{startId} AND id<=#{endId}")
	public List<Project> getBatchPrjs(@Param("startId") int startId, @Param("endId") int endId);
	
}
